﻿Public Class BlockFiveHomeworkSectionFour
    Dim QuestionNumber As Integer
    Dim dtmTest, dtmTest2 As Date
    Dim filename As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    'Declare the Array as 10 rows and 3 columns
    Dim ArrayMax As Integer = 34 'One number past the end of actual info in array
    Dim HWQuestions(ArrayMax, 7) As String
    Dim intResponse As Integer
    Dim intQuestionCount As Integer = 0
    Dim intAnswerCount As Integer = 0
    Dim intReferenceCount As Integer = 0
    Dim intFirstRun As Integer = 1
    Dim strUser As String = "Enter Last Name"
    Dim strAnswer, strAnswer2, strAnswer3, strAnswer4, strAnswer5, _
     strAnswer6, strAnswer7, strAnswer8, strAnswer9, strAnswer10, strAnswer11, _
     strAnswer12, strAnswer13, strAnswer14, strAnswer15, strAnswer16, _
     strAnswer17, strAnswer18, strAnswer19, strAnswer20, strAnswer21, _
     strAnswer22, strAnswer23, strAnswer24, strAnswer25, strAnswer26, _
     strAnswer27, strAnswer28, strAnswer29, strAnswer30, strAnswer31, strAnswer32 As String
    Dim intChoiceACount As Integer = 2
    Dim intChoiceBCount As Integer = 3
    Dim intChoiceCCount As Integer = 4
    Dim intChoiceDCount As Integer = 5

    Shared Property MidiParent As MainForm

    Private Sub CloseToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles CloseToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub BlockTwoHomeworkSectionOne_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        txtObj.Text = "Objectives:" + vbCrLf + "- Given proper student instructional materials, describe the system buses." _
                                    + vbCrLf + "- Given proper student instructional materials, describe system interconnection." _
                                    + vbCrLf + "- Given proper student instructional materials, describe the transmit and receive audio path." _
                                    + vbCrLf + "- Given proper student instructional materials, describe the configuration and control subsystem." _
                                    + vbCrLf + "- Given proper student instructional materials, describe the ETVS power distribution."
        If (System.IO.File.Exists(filename & "\Homework\Block 5\Block 5 Section 4.txt")) Then
            intResponse = MsgBox("This assignment has already been completed.  Are you sure you want to delete the current assignment and reaccomplish it?", 4, "Confirm Assignment Deletion")
            If intResponse = MsgBoxResult.Yes Then
                System.IO.File.Delete(filename & "\Homework\Block 5\Block 5 Section 4.txt")
                System.IO.File.Create(filename & "\Homework\Block 5\Block 5 Section 4.txt").Dispose()
            ElseIf intResponse = MsgBoxResult.No Then
                Me.Close()
            End If
        End If
        If (Not System.IO.File.Exists(filename & "\Homework\Block 5\Block 5 Section 4.txt")) Then
            System.IO.File.Create(filename & "\Homework\Block 5\Block 5 Section 4.txt").Dispose()
        End If
        If (Not System.IO.File.Exists(filename & "\Instructor\Block 5\Block 5 Section 4.txt")) Then
            System.IO.File.Create(filename & "\Instructor\Block 5\Block 5 Section 4.txt").Dispose()
        End If
        strUser = InputBox("Please enter last name", strUser)
        If strUser Is "" Then
            Me.Close()
        End If
        '************************************************
        '****** Questions Are Loaded Here****************
        '******* Column 1 is Questions (Preloaded)*******
        '******* Column 2 is Accepts Students Answer*****
        '******* Column 3 is Reference ******************

        HWQuestions(1, 1) = "1 A rack unit 'U' equals __________ inches. "
        HWQuestions(1, 2) = "1.25"
        HWQuestions(1, 4) = "1.75"
        HWQuestions(1, 5) = "7.00"
        HWQuestions(1, 6) = "8.75"
        HWQuestions(1, 3) = "Reference"

        HWQuestions(2, 1) = "2. The TMU/CMU places up-link data from each cluster on ______ of the 16 differential pairs of the Cluster Bus."
        HWQuestions(2, 2) = strAnswer2
        HWQuestions(2, 3) = "Reference"

        HWQuestions(3, 1) = "3. The Control Data Bus allows circuit cards in the central rack to pass __________ and __________ data to each other."
        HWQuestions(3, 2) = strAnswer3
        HWQuestions(3, 3) = "Reference"

        HWQuestions(4, 1) = "4. The Voice Data Bus contains digitized _______ data for active channels and ________ data for inactive channels."
        HWQuestions(4, 2) = strAnswer4
        HWQuestions(4, 3) = "Reference"

        HWQuestions(5, 1) = "5. Every operator processor, radio processor, and telephone conferencer can access the same byte of data on the Voice Data Bus simultaneously. "
        HWQuestions(5, 2) = "True"
        HWQuestions(5, 4) = "False"
        HWQuestions(5, 5) = ""
        HWQuestions(5, 6) = ""
        HWQuestions(5, 3) = "Reference"

        HWQuestions(6, 1) = "6. To designate a card cage as number 19 in the system, W100 is jumpered _______ and switch S1 is set for _______."
        HWQuestions(6, 2) = "W100=1 to 2 and S1=6"
        HWQuestions(6, 4) = "W100=2 to 3 and S1=7"
        HWQuestions(6, 5) = "W100=1 to 2 and S1=3"
        HWQuestions(6, 6) = "W100=2 to 3 and S1=4"
        HWQuestions(6, 3) = "Reference"

        HWQuestions(7, 1) = "7. The cluster up-links and down-links are found on each '5U' backplane. "
        HWQuestions(7, 2) = "True"
        HWQuestions(7, 4) = "False"
        HWQuestions(7, 5) = ""
        HWQuestions(7, 6) = ""
        HWQuestions(7, 3) = "Reference"

        HWQuestions(8, 1) = "8. There is no _________ required for ETVS telephone circuits."
        HWQuestions(8, 2) = "operator"
        HWQuestions(8, 4) = "clear channel"
        HWQuestions(8, 5) = "distribution panel"
        HWQuestions(8, 6) = "lightning protection"
        HWQuestions(8, 3) = "Reference"

        HWQuestions(9, 1) = "9. ______ and ______ connect to the backplane connectors of two phone conferencers that process ST data from the telephone interface cards. "
        HWQuestions(9, 2) = "J17 and J18"
        HWQuestions(9, 4) = "J19 and J20"
        HWQuestions(9, 5) = "J 21 and J22"
        HWQuestions(9, 6) = "J23 and J24"
        HWQuestions(9, 3) = "Reference"

        HWQuestions(10, 1) = "10. Each telephone line interface card provides its own legal record feed to the DVRS via the demarc."
        HWQuestions(10, 2) = "True"
        HWQuestions(10, 4) = "False"
        HWQuestions(10, 5) = ""
        HWQuestions(10, 6) = ""
        HWQuestions(10, 3) = "Reference"

        HWQuestions(11, 1) = "1. A ________________ in the Operator Processor places voice data into a time slot on the PCM HWY up-link to the Multiplexer Unit."
        HWQuestions(11, 2) = strAnswer
        HWQuestions(11, 3) = "Reference"

        HWQuestions(12, 1) = "2. A _________ in the Radio Processor is used to pick voice data off the VDB."
        HWQuestions(12, 2) = "cross-pint switch"
        HWQuestions(12, 4) = "time slot counter"
        HWQuestions(12, 5) = "CODEC"
        HWQuestions(12, 6) = "DSP"
        HWQuestions(12, 3) = "Reference"

        HWQuestions(13, 1) = "3. A ________ in the Conferencer is used to sum audio during conferences."
        HWQuestions(13, 2) = strAnswer3
        HWQuestions(13, 3) = "Reference"

        HWQuestions(14, 1) = "4. A __________ in the Radio Processor places voice data into a time slot on the PCM HWY up-link to the Multiplexer Unit."
        HWQuestions(14, 2) = "cross-point switch"
        HWQuestions(14, 4) = "time slot counter"
        HWQuestions(14, 5) = "CODEC"
        HWQuestions(14, 6) = "DSP"
        HWQuestions(14, 3) = "Reference"

        HWQuestions(15, 1) = "5. A __________ on each Telephone Line Interface card places voice data into a time slot on the Dual ST Bus to the Conferencer."
        HWQuestions(15, 2) = "cross-point switch"
        HWQuestions(15, 4) = "time slot counter"
        HWQuestions(15, 5) = "CODEC"
        HWQuestions(15, 6) = "DSP"
        HWQuestions(15, 3) = "Reference"

        HWQuestions(16, 1) = "1. The Configuration Control Group consists of: (6 items)"
        HWQuestions(16, 2) = strAnswer16
        HWQuestions(16, 3) = "Reference"

        HWQuestions(17, 1) = "2. User interface is provided by the ______________________________ for system configuration and maintenance purposes."
        HWQuestions(17, 2) = strAnswer17
        HWQuestions(17, 3) = "Reference"

        HWQuestions(18, 1) = "3. After defining the configuration, the user saves it as a map file to the _______________ hard drive."
        HWQuestions(18, 2) = strAnswer18
        HWQuestions(18, 3) = "Reference"

        HWQuestions(19, 1) = "4. For the system to function, the desired map on the Gateway/SCT hard drive is written to the ________ in each of the system device processors."
        HWQuestions(19, 2) = strAnswer19
        HWQuestions(19, 3) = "Reference"

        HWQuestions(20, 1) = "5. A bus failure is reported to the configuration terminals which initiate a SYSTEM FAULT alarm to the ________________ panel."
        HWQuestions(20, 2) = strAnswer20
        HWQuestions(20, 3) = "Reference"

        HWQuestions(21, 1) = "6. Initialization takes place during system _______________."
        HWQuestions(21, 2) = strAnswer21
        HWQuestions(21, 3) = "Reference"

        HWQuestions(22, 1) = "7. Local maps are developed for each __________.."
        HWQuestions(22, 2) = strAnswer22
        HWQuestions(22, 3) = "Reference"

        HWQuestions(23, 1) = "8. The __________ map includes the data generated for all the local maps plus unit slot locations and channel assignments."
        HWQuestions(23, 2) = strAnswer23
        HWQuestions(23, 3) = "Reference"

        HWQuestions(24, 1) = "9. The Gateway/SCT computer communicates with the ____________________ via a router and Nport."
        HWQuestions(24, 2) = strAnswer24
        HWQuestions(24, 3) = "Reference"

        HWQuestions(25, 1) = "10. The High Speed Serial Interface reads and writes data to/from both ___________ buses via the Nport."
        HWQuestions(25, 2) = strAnswer25
        HWQuestions(25, 3) = "Reference"

        HWQuestions(26, 1) = "1. ETVS central equipment operates from a mains voltage of ______ VAC."
        HWQuestions(26, 2) = strAnswer26
        HWQuestions(26, 3) = "Reference"

        HWQuestions(27, 1) = "2. A minimum of ______ power supplies are installed for redundancy purposes, larger systems may require up to ______."
        HWQuestions(27, 2) = strAnswer27
        HWQuestions(27, 3) = "Reference"

        HWQuestions(28, 1) = "3. The power supply modules provide ______ VDC to the ETVS system."
        HWQuestions(28, 2) = strAnswer28
        HWQuestions(28, 3) = "Reference"

        HWQuestions(29, 1) = "4. The central rack houses the reserve batteries that power the system for up to ______ minutes in the event of main power failure."
        HWQuestions(29, 2) = strAnswer29
        HWQuestions(29, 3) = "Reference"

        HWQuestions(30, 1) = "5. If a fuse blows, the indicator adjacent to and to the right of the blown fuse __________ and an alarm sounds at the System Alarm Panel."
        HWQuestions(30, 2) = strAnswer30
        HWQuestions(30, 3) = "Reference"

        HWQuestions(31, 1) = "6. The Low-Voltage Battery Panel disconnects the batteries from the load if the battery voltage drops below ______ VDC."
        HWQuestions(31, 2) = strAnswer31
        HWQuestions(31, 3) = "Reference"

        HWQuestions(32, 1) = "7. When main power is restored the LVD panels reconnect the load to the power supplies after the battery charge reaches ______ VDC."
        HWQuestions(32, 2) = strAnswer32
        HWQuestions(32, 3) = "Reference"

        HWQuestions(33, 1) = "Close"

        Next_Question(HWQuestions)
    End Sub

    Private Sub btnNextQuestion_Click(sender As System.Object, e As System.EventArgs) Handles btnNextQuestion.Click
        Next_Question(HWQuestions)
    End Sub
    Private Sub Clear_Display()
        txtQuestion.Clear()
        txtAnswer.Clear()
    End Sub

    Public Function Next_Question(HWQuestions As String(,))
        txtAnswer.Focus()
        If intQuestionCount > 0 Then
            WriteToFile()
        End If
        If btnNextQuestion.Text = "Done" Then
            Me.Close()
            OpenResults()
        End If
        intQuestionCount = intQuestionCount + 1
        LabelChangeCheck()
        If intQuestionCount = 32 Then
            btnNextQuestion.Text = "Done"
        End If
        If intQuestionCount = 1 Or intQuestionCount = 5 Or intQuestionCount = 6 Or intQuestionCount = 7 _
            Or intQuestionCount = 8 Or intQuestionCount = 9 Or intQuestionCount = 10 Or intQuestionCount = 12 _
            Or intQuestionCount = 14 Or intQuestionCount = 15 Then
            txtAnswer.Visible = False
            lblAnswer.Visible = False
            txtChoiceA.Visible = True
            txtChoiceB.Visible = True
            txtChoiceC.Visible = True
            txtChoiceD.Visible = True
            lblChoiceA.Visible = True
            lblChoiceB.Visible = True
            lblChoiceC.Visible = True
            lblChoiceD.Visible = True
            chkboxChoiceA.Visible = True
            chkboxChoiceB.Visible = True
            chkboxChoiceC.Visible = True
            chkboxChoiceD.Visible = True

            txtQuestion.Text = HWQuestions(intQuestionCount, 1)
            txtChoiceA.Text = HWQuestions(intQuestionCount, 2)
            txtChoiceB.Text = HWQuestions(intQuestionCount, 4)
            txtChoiceC.Text = HWQuestions(intQuestionCount, 5)
            txtChoiceD.Text = HWQuestions(intQuestionCount, 6)

        ElseIf intQuestionCount = 2 Or intQuestionCount = 3 Or intQuestionCount = 4 Or intQuestionCount = 11 _
            Or intQuestionCount = 13 Or intQuestionCount >= 16 Then
            txtAnswer.Visible = True
            lblAnswer.Visible = True
            txtChoiceA.Visible = False
            txtChoiceB.Visible = False
            txtChoiceC.Visible = False
            txtChoiceD.Visible = False
            lblChoiceA.Visible = False
            lblChoiceB.Visible = False
            lblChoiceC.Visible = False
            lblChoiceD.Visible = False
            chkboxChoiceA.Visible = False
            chkboxChoiceB.Visible = False
            chkboxChoiceC.Visible = False
            chkboxChoiceD.Visible = False

            txtQuestion.Text = HWQuestions(intQuestionCount, 1)
            intAnswerCount = intAnswerCount + 1
            HWQuestions(intAnswerCount, 2) = txtAnswer.Text
            intReferenceCount = intReferenceCount + 1
            txtReference.Text = HWQuestions(intReferenceCount, 3)
            txtAnswer.Focus()
        End If
        Return intQuestionCount & intAnswerCount
    End Function

    Private Sub LabelChangeCheck()
        If intQuestionCount = 1 Then
            lblSubject.Text = "System Architecture"
        ElseIf intQuestionCount = 11 Then
            lblSubject.Text = "Audio Paths"
        ElseIf intQuestionCount = 16 Then
            lblSubject.Text = "Configuration Control Group"
        ElseIf intQuestionCount = 26 Then
            lblSubject.Text = "Power Distribution Subsystem"
        End If
    End Sub

    Private Sub WriteToFile()
        Dim Integrity As String = (filename & "\Instructor\Block 5\Block 5 Section 4.txt")
        Dim Results As String = (filename & "\Homework\Block 5\Block 5 Section 4.txt")

        '***********Output to hidden file for Instructor Check***********
        If System.IO.File.Exists(Integrity) = True Then
            Dim hiddenWriter As New System.IO.StreamWriter(Integrity, True)
            If intQuestionCount = 1 Then
                hiddenWriter.WriteLine()
                hiddenWriter.WriteLine("Student: " & strUser)
                hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If
            hiddenWriter.WriteLine("Question:" & txtQuestion.Text)
            If intQuestionCount = 1 Or intQuestionCount = 5 Or intQuestionCount = 6 Or intQuestionCount = 7 _
    Or intQuestionCount = 8 Or intQuestionCount = 9 Or intQuestionCount = 10 Or intQuestionCount = 12 _
    Or intQuestionCount = 14 Or intQuestionCount = 15 Then
                If chkboxChoiceA.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  A: " & txtChoiceA.Text)
                ElseIf chkboxChoiceB.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  B: " & txtChoiceB.Text)
                ElseIf chkboxChoiceC.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  C: " & txtChoiceC.Text)
                ElseIf chkboxChoiceD.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  D: " & txtChoiceD.Text)
                End If
                hiddenWriter.WriteLine()
            End If
            If chkboxChoiceA.Visible = False Then
                hiddenWriter.WriteLine("Answer:" & txtAnswer.Text)
                hiddenWriter.WriteLine()
            End If
            hiddenWriter.WriteLine("Answer:" & txtAnswer.Text)
            hiddenWriter.WriteLine()
            If intQuestionCount = 32 Then
                hiddenWriter.WriteLine("Block 5 Section 4 Homework Complete")
                hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If
            hiddenWriter.Close()

            'MsgBox("Text written to file")
        Else
            MsgBox("File Does Not Exist Integrity")
        End If

        '******Output to file for Student to review***********
        If System.IO.File.Exists(Results) = True Then
            Dim hiddenWriter As New System.IO.StreamWriter(Results, True)
            If intQuestionCount = 1 Then
                hiddenWriter.WriteLine("- " & txtObj.Text)
                hiddenWriter.WriteLine()
                hiddenWriter.WriteLine("Student: " & strUser)
                hiddenWriter.WriteLine()
            End If
            If intQuestionCount = 1 Then
                hiddenWriter.WriteLine(lblSubject.Text)
            ElseIf intQuestionCount = 11 Then
                hiddenWriter.WriteLine(lblSubject.Text)
            ElseIf intQuestionCount = 16 Then
                hiddenWriter.WriteLine(lblSubject.Text)
            ElseIf intQuestionCount = 26 Then
                hiddenWriter.WriteLine(lblSubject.Text)
            End If
            hiddenWriter.WriteLine("Question:" & txtQuestion.Text)
            If intQuestionCount = 1 Or intQuestionCount = 5 Or intQuestionCount = 6 Or intQuestionCount = 7 _
            Or intQuestionCount = 8 Or intQuestionCount = 9 Or intQuestionCount = 10 Or intQuestionCount = 12 _
            Or intQuestionCount = 14 Or intQuestionCount = 15 Then
                If chkboxChoiceA.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  A: " & txtChoiceA.Text)
                ElseIf chkboxChoiceB.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  B: " & txtChoiceB.Text)
                ElseIf chkboxChoiceC.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  C: " & txtChoiceC.Text)
                ElseIf chkboxChoiceD.CheckState = 1 Then
                    hiddenWriter.WriteLine("Answer:  D: " & txtChoiceD.Text)
                End If
                hiddenWriter.WriteLine()
            End If
            If chkboxChoiceA.Visible = False Then
                hiddenWriter.WriteLine("Answer:" & txtAnswer.Text)
                hiddenWriter.WriteLine()
            End If
            hiddenWriter.WriteLine("Answer:" & txtAnswer.Text)
            hiddenWriter.WriteLine()
            If intQuestionCount = 32 Then
                hiddenWriter.WriteLine("Block 5 Section 4 Homework Complete")
                hiddenWriter.WriteLine("Date: " & (DateValue(Now)))
                hiddenWriter.WriteLine("Time: " & (TimeValue(Now)))
            End If
            hiddenWriter.Close()

            'MsgBox("Text written to file")
        Else
            MsgBox("File Does Not Exist Results")
        End If

        If intQuestionCount > 0 Then
            txtAnswer.Clear()
            chkboxChoiceA.CheckState = CheckState.Unchecked
            chkboxChoiceB.CheckState = CheckState.Unchecked
            chkboxChoiceC.CheckState = CheckState.Unchecked
            chkboxChoiceD.CheckState = CheckState.Unchecked
        End If

    End Sub

    Private Sub OpenResults()
        Dim p As Process = Process.Start(filename & "\Homework\Block 5\Block 5 Section 4.txt")
    End Sub
End Class
